import { Socket } from 'socket.io';
import { logger } from '../utils/logger';

export class Player {
	constructor(
		readonly playerId: string,
		private socket: Socket,
	) {}
	private name: string = '';

	/**
	 * 设置玩家名称
	 * @param name
	 */
	setName(name: string) {
		this.name = name;
		logger.info(`SetPlayerName: ${this.playerId} ${name}`);
	}

	/**
	 * 获取玩家名称
	 * @returns
	 */
	getName(): string {
		return this.name;
	}

	/**
	 * 获取玩家Socket
	 * @returns
	 */
	getSocket() {
		return this.socket;
	}
}
